<template>
  <div class="upFileContainer">
    <div class="upFileBox">
      <label for="upFile">选择Excel</label>
      <input type="file" id="upFile" style="display: none;" accept=".xls,.xlsx" name="file" @change="fileChangeFun">
      <input type="text" class="fileName" disabled v-model="fileName">
      <a href="javascript:;" class="download">模板下载.xls</a>
    </div>
    <button class="importFile">导入</button>
  </div>
</template>

<script>
export default {
  data(){
    return {
      fileName: '选择要导入的Excel......'
    }
  },
  methods: {
    fileChangeFun() {
      // 使用 - 元素对象.files[0].name 可只获取文件名
      this.fileName = document.getElementById('upFile').value
    }
  }
}
</script>

<style lang='less'>
  .upFileContainer{
    background: #fff;
    padding: 15px 20px;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    border-radius: 5px;
    box-shadow: 1px 4px 5px 1px #ccc;
    .upFileBox{
      display: flex;
      align-items: center;
      .download{
        width: 75px;
        height: 24px;
        border: 2px dashed #ccc;
        color: #333;
        font-size: 12px;
        margin-left: 10px;
        padding-left: 20px;
        line-height: 24px;
        background: url('../../../assets/images/icon_tupian.png') no-repeat 6px center;
      }
    }
    label,.importFile{
      display: inline-block;
      width: 100px;
      height: 26px;
      border: 1px solid #eee;
      box-shadow: 0px 1px 1px 1px #ccc;
      background: #6768ff;
      border-radius: 6px;
      margin: 0 8px 0 0;
      line-height: 26px;
      text-align: center;
      color: #fff;
    }
    .fileName{
      width: 606px;
      height: 24px;
      border: 2px solid #ccc;
      color: #7d7d7d;
      padding-left: 10px;
      font-size: 12px;
    }
    .importFile{
      width: 115px;
      height: 32px;
      margin: 36px 0 0 109px;
    }
    .importFile:hover,label:hover{
      opacity: 0.7;
    }
    .importFile:active,label:active{
			opacity: 1;
		}
  }
</style>